import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

function lazyRouter (view) {
  return resolve => (require([`@/view/${view}`], resolve))
}

export default new Router({
  routes: [
    {
      path: '/',
      name: 'Index',
      component: lazyRouter('index')
    },
    {
      path: '/category/:id?',
      name: 'Category',
      component: lazyRouter('category')
    },
    {
      path: '/detail/:id',
      name: 'Detail',
      component: lazyRouter('detail')
    },
    {
      path: '/shopcart',
      name: 'Shopcart',
      component: lazyRouter('shopcart')
    },
    {
      path: '/order',
      name: 'Order',
      component: lazyRouter('order')
    }
  ]
})
